home *** CD-ROM | disk | FTP | other *** search
- Path: news.magicnet.net!usenet
- From: gamecox@magicnet.net (Jody Hagins)
- Newsgroups: comp.lang.c++
- Subject: Re: Pure Virtual Destructor Question
- Date: 11 Feb 1996 01:36:15 GMT
- Organization: MagicNet, Inc.
- Message-ID: <4fjh6f$8v0@comet2.magicnet.net>
- References: <4fas7a$7ns@comet2.magicnet.net> <4fecq0$k4e@news4.digex.net>
- NNTP-Posting-Host: pm1-04.magicnet.net
- X-Newsreader: WinVN 0.92.6+
-
- In article <4fecq0$k4e@news4.digex.net>, ell@access4.digex.net (Ell) says:
- >
- >Jody Hagins (gamecox@magicnet.magicnet.net) wrote:
- >: Assume a class Foo s.t.
- >:
- >: class Foo
- >: {
- >: public:
- >: virtual ~Foo() = 0;
- >: };
- >:
- >: inline Foo::~Foo()
- >: {
- >: // do some destructor stuff
- >: }
- >
- >Immediately above you are logically "defining" your "pure virtual"
- >destructor "inside the class where it is "declared" as a pure virtual
- >function. It is _illegal_ to logically, or physically "define" a pure
- >virtual function in the class it is "declared" in. A pure virtual should
- >only be defined in classes derived from the class where the pure virtual
- >is declared. Only derived classes should "do some destructor stuff".
-
-
- No, that's not correct. I've received several replies with this same
- comment, so I'll give the appropriate response. First, thanks for
- replying, it's what makes this group great. There's always tons of
- peolpe willing to help.
-
- Now, for the pure virtual function lesson. If you don't want my
- version, look in Meyers' Effective C++, item 36.
-
- A pure virtual function *can* have default behavior. For example,
-
- class Foo
- {
- public:
- virtual void Bar() = 0;
- };
-
- void Foo::Bar()
- {
- cout "Foo::Bar() default function called" << endl;
- }
-
- is perfectly legal, and I get this to work with no problem. However,
- the problem comes in if you try to "automatic inline" the function with
- the class declaration. Then, I get compiler errors, and that's what I
- believe I should be able to do.
-
- I've received on response indicating that the following works fine on
- his compiler...
-
-
- class Foo
- {
- public:
- virtual ~Foo() = 0 { }
- };
-
-
- However, mine (based on at&t cfront 3.0) barfs on it.
-
- Thanks,
- -Jody
-
-